package cn.kgc.mvc.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author: mosin
 * @version: v1.0  2022/7/8
 */
@Controller
@RequestMapping("ex")
public class MyExceptionController {


    //@ExceptionHandler(ArithmeticException.class)
    //public String arithmeticExceptionHandler(Exception exception){
    //    System.out.println(exception.getMessage());
    //    return "error";
    //}


    //@ExceptionHandler()
    //public String exceptionHandler(Exception exception){
    //    System.out.println(exception.getMessage());
    //    return "error";
    //}



    @RequestMapping("ex1")
    @ResponseBody
    public String ex1(){

        int a = 1/0;

        return "ex1 ok";
    }

    @RequestMapping("ex2")
    @ResponseBody
    public String ex2(){

        String str = null;
        System.out.println(str.length());
        return "ex2 ok";
    }


}
